using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class UDF_RecordTypeMap : EntityTypeConfiguration<UDF_RecordType>
    {
        public UDF_RecordTypeMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.RecordType, t.Id_FIELD, t.TableName, t.Name1, t.Value1, t.Name2, t.Value2, t.Name3, t.Value3 });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.RecordType)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Id_FIELD)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.TableName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Name1)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Value1)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Name2)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Value2)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Name3)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Value3)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("UDF_RecordType");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.Id_FIELD).HasColumnName("Id_FIELD");
            this.Property(t => t.TableName).HasColumnName("TableName");
            this.Property(t => t.Name1).HasColumnName("Name1");
            this.Property(t => t.Value1).HasColumnName("Value1");
            this.Property(t => t.Name2).HasColumnName("Name2");
            this.Property(t => t.Value2).HasColumnName("Value2");
            this.Property(t => t.Name3).HasColumnName("Name3");
            this.Property(t => t.Value3).HasColumnName("Value3");
        }
    }
}
